package com.gdziarmaga.webshop.transaction.model;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import com.gdziarmaga.webshop.login.model.Login;

@Entity
@Table(name = "Transaction")
public class Transaction implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private long transaction_id;
	private int realised;

	@Column(name = "realised", precision = 20, scale = 0)
	public int getRealised() {
		return realised;
	}

	public void setRealised(int realised) {
		this.realised = realised;
	}

	private Login login;
	

	public void setTransaction_id(long transaction_id) {
		this.transaction_id = transaction_id;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "transaction_seq")
	@SequenceGenerator(name = "transaction_seq", sequenceName = "TRANSACTION_SEQ")
	@Column(name = "transaction_id", precision = 20, scale = 0, unique=true)
	public long getTransaction_id() {
		return transaction_id;
	}

	public void setLogin(Login login) {
		this.login = login;
	}
	
	@ManyToOne(cascade = CascadeType.PERSIST, fetch=FetchType.EAGER)
    @JoinColumn(name = "login_id", nullable=false, updatable=false)
	public Login getLogin() {
		return login;
	}

}
